package pers.cj.pdos.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import pers.cj.pdos.cache.CacheData;
import pers.cj.pdos.constant.CacheConstant;
import pers.cj.pdos.entity.Permission;
import pers.cj.pdos.mapper.PermissionMapper;
import pers.cj.pdos.service.IPermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenj
 * @since 2019-11-04
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements IPermissionService {
    @Autowired
    PermissionMapper permissionMapper;

    @Override
    @CacheData(clazz = PermissionServiceImpl.class)
    public List<Permission> listAll() {
        return permissionMapper.selectList(null);
    }

    @CacheData(clazz = PermissionServiceImpl.class, param = "#userId")
    @Override
    public List<Permission> findByUserId(String userId) {
        System.out.println("-------------------------------findByUserId---------------------------------------------------");
        return permissionMapper.findByUserId(userId);
    }

    @Override
    public void insertBatch(List<Permission> list) {
        permissionMapper.insertBatch(list);
    }
}
